#!/usr/bin/env bash

# ----------------------------------------------------------------------
# Filename:   01-service-dev.sh
# Version:    1.0
# Date:       2020/07/08
# Author:     Lz
# Email:      lz843723683@gmail.com
# History：     
#             Version 1.0, 2020/07/08
# Function:   开发版 - 默认服务和软件包（开发版）
# Out:        
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------

## TODO : 测试收尾清除工作
#
SvcClean_FTLYY_DEV(){
	return $TPASS
}


## TODO: 调用程序退出函数
#    In: $1 => 调用脚本结果值
SvcExit_FTLYY_DEV(){
        # 调用退出函数，其中调用了clean相关函数
	Exit_FTLIB ${1}
}


## TODO: 用户界面
#
SvcUSAGE_FTLYY_DEV(){
	USAGE_FTLIB "联研院开发版 - 开发版"
}


## TODO : 测试前的初始化 
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other=> TCONF
SvcInit_FTLYY_DEV(){
        # 调用初始化函数
	Init_FTLIB "SvcClean_FTLYY_DEV"
        # 调用用户界面函数
 	SvcUSAGE_FTLYY_DEV
}


## TODO ：默认开启服务：psacct、network、firewalld、crond、cups、auditd、rsyslog、smartd、sysstat、acpid
#
SvcTest01_FTLYY_DEV(){
        local svcArr="sshd psacct network firewalld crond cups auditd rsyslog smartd sysstat acpid"

        SvcActiveArr_FTLIB "isActive" "no" "$svcArr"
        RetParse_FTLIB "要求已经激活以下服务 ${svcArr}" "False"

        SvcEnableArr_FTLIB "isEnable" "no" "$svcArr"
        RetParse_FTLIB "要求开机自启动以下服务 ${svcArr}" "False"
}


## TODO ：默认安装:acl acpid adjtimex at attr audit autoconf automake bash bc binutils bison byacc bzip2 coreutils cpio crontabs dialog diffutils e2fsprogs util-linux expat expect file findutils flex gawk gcc gdb gettext glibc grep grub2-common gzip hdparm iproute iptables iputils kbd less libaio libarchive libcap libmac libpcap libtool-ltdl libusb libxml2 libxslt lm-sensors logrotate lvm2 m4 make man-db man-pages kmod mysql ncurses net-tools ntp openssh openssl patch pciutils perl pkgconfig procps-ng psmisc python readline rpm sed smartmontools sqlite3 strace subversion libsysfs2 rsyslog sysstat sysvinit tar tcl tcpdump tcsh time traceroute libgudev1 unixODBC usbutils util-linux vim wget xfsprogs zlib
#
SvcTest02_FTLYY_DEV(){
	local pkgArr="acl acpid adjtimex at attr audit autoconf automake bash bc binutils bison byacc bzip2 coreutils cpio crontabs dialog diffutils e2fsprogs util-linux expat expect file findutils flex gawk gcc gdb gettext glibc grep grub2-common gzip hdparm iproute iptables iputils kbd less libaio libarchive libcap libmac libpcap libtool-ltdl libusb libxml2 libxslt lm_sensors logrotate lvm2 m4 make man-db man-pages kmod ncurses net-tools ntp openssh openssl patch pciutils perl pkgconfig procps-ng psmisc python readline rpm sed smartmontools sqlite strace subversion libsysfs rsyslog sysstat sysvinit-tools tar tcl tcpdump tcsh time traceroute libgudev1 unixODBC usbutils util-linux wget xfsprogs zlib"

	PkgExistArr_FTLIB "isExist" "no" "yes" "$pkgArr"
	RetParse_FTLIB "要求默认安装：${pkgArr}" "False"
	
	# 模糊匹配
	pkgArr="mysql vim"
	PkgExistArr_FTLIB "isExist" "no" "no" "$pkgArr"
	RetParse_FTLIB "要求默认安装：${pkgArr}" "False"
}


## TODO : Main
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other => TCONF
SvcMain_FTLYY_DEV(){
	SvcInit_FTLYY_DEV

	SvcTest01_FTLYY_DEV

	SvcTest02_FTLYY_DEV

	return ${TPASS}	
}

SvcMain_FTLYY_DEV
SvcExit_FTLYY_DEV $?
